﻿using AttributeDemo.UseAttribute;
using Newtonsoft.Json;
using System;

namespace AttributeDemo
{
    class Program
    {
       static void Main(string[] args)
        {
            People people = new People()
            {
                Idcard = "370983199706151234",
                Name = "李燕茹",
                Sex = SexEnum.Woman,
                Birthday =DateTime.Parse("1997-06-15"),
                Address = "山东泰安"
            };
            ChinesePeople chinesePeople = new ChinesePeople()
            {
                Idcard = "3709831997061512341",
                Name = "智能机器人",
                Sex = SexEnum.Woman,
                Birthday = DateTime.Parse("2022-06-15"),
                Address = "中国"
            };

            InvokeCenter.ManagerPeople<ChinesePeople>(chinesePeople);


            #region 单个特性使用
            //string sex = people.Sex.GetSummary();
            //bool idcard = UseIdCardAttribute.Validate(people);
            //bool brithday = UseBrithdayAttribute.Validate(people);

            //Console.WriteLine($"身份证号校验是否通过：{idcard}");       
            //Console.WriteLine($"出生日期校验是否通过：{brithday}");
            #endregion

            #region 抽象特性使用
            //var validateResult = people.Validate();
            //if (!validateResult.IsValid)
            //{
            //    Console.WriteLine(JsonConvert.SerializeObject(validateResult.Errors));
            //}
            #endregion
        }
    }
}
